package com.example.b_308.myapplication.view.user.login;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;

import com.example.b_308.myapplication.R;
import com.example.b_308.myapplication.comment.utils.Global;
import com.example.b_308.myapplication.view.base.BaseActivity;

/**
 * Created by B-308 on 2017/11/28.
 */
public class ModifyActivity extends BaseActivity implements View.OnClickListener {
    EditText et_password_modify, et_password_verity_modify;
    ImageView iv_pm_eye, iv_pvm_eye;
    Button btn_complete;
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        initView();
        initListenerForget();
    }

    private void initListenerForget() {
        iv_pm_eye.setOnClickListener(this);
        iv_pvm_eye.setOnClickListener(this);
        btn_complete.setOnClickListener(this);
        et_password_modify.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {

            }

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
                if(s.length() == 0){
                    iv_pm_eye.setVisibility(View.GONE);
                }else{
                    iv_pm_eye.setVisibility(View.VISIBLE);
                }
            }

            @Override
            public void afterTextChanged(Editable s) {

            }
        });
        et_password_verity_modify.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {

            }

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
                if(s.length() == 0){
                    iv_pvm_eye.setVisibility(View.GONE);
                }else{
                    iv_pvm_eye.setVisibility(View.VISIBLE);
                }
            }

            @Override
            public void afterTextChanged(Editable s) {

            }
        });

    }

    private void initView() {
        setContentView(R.layout.activity_modify);
        getTitleBar().setTitle(Global.getString(R.string.password_modify));
        getTitleBar().getTv_setting().setVisibility(View.GONE);
        getTitleBar().getIv_setting().setVisibility(View.GONE);
        getTitleBar().getTv_return().setVisibility(View.GONE);
        et_password_modify = findView(R.id.et_password_modify);
        et_password_verity_modify = findView(R.id.et_password_verity_modify);
        iv_pm_eye = findView(R.id.iv_pm_eye);
        iv_pvm_eye = findView(R.id.iv_pvm_eye);
        btn_complete = findView(R.id.btn_complete);
    }

    @Override
    public void fail(String message) {

    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.iv_pm_eye:
                break;
            case R.id.iv_pvm_eye:
                break;
            case R.id.btn_complete:
                tend2(ModifyActivity.class);
                break;
        }

    }

}
